package com.hrbxlh.actionImpl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.hrbxlh.dao.ParamDao;
/**
* -------------------------------------------------------
* Copyright (c) 2017, 鑫联华信息科技股份有限公司
* All rights reserved.
* FileName：ParamActionImpl.java
* Description：参数管理actionImpl类
* History：
* Date           Author               Desc
* 2017.04.17	  xzx                  建立	
* -------------------------------------------------------
*/
@Component("paramActionImpl")
@Transactional
public class ParamActionImpl {

	@Resource(name = "paramDao")
	private ParamDao paramDao;
	
	/**
	 * @description 获取参数信息
	 * @param Map<String,Object> paramMap
	 * @return Map<String,Object>
	 * @throws Exception
	 */
	public Map<String, Object> getParamDetail() throws Exception {
		
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			map = paramDao.getParamDetail();
		} catch (Exception e) {
			throw e;
		}
		return map;
	}
	
	/**
	 * @description 修改参数
	 * @param Map<String,Object> paramMap
	 * @return Map<String,Object>
	 * @throws Exception
	 */
	public boolean saveParam(Map<String, Object> paramMap) throws Exception {
		
		boolean result = false;
		try {
			paramDao.saveParam(paramMap);
			result = true;
		} catch (Exception e) {
			throw e;
		}
		return result;
	}
	
	/**
	 * @description 将classNum与time对应起来
	 * @return Map<String,Object>
	 * @throws Exception
	 */
	public Map<String,Object> matchClassNumAndTime() throws Exception {
		
		Map<String, Object> map = new HashMap<String, Object>();
		try {
			Map<String, Object> paramMap = this.getParamDetail();
			map.put("1start", paramMap.get("upOneStart"));
			map.put("1end", paramMap.get("upOneEnd"));
			map.put("2start", paramMap.get("upTwoStart"));
			map.put("2end", paramMap.get("upTwoEnd"));
			map.put("3start", paramMap.get("downOneStart"));
			map.put("3end", paramMap.get("downOneEnd"));
			map.put("4start", paramMap.get("downTwoStart"));
			map.put("4end", paramMap.get("downTwoEnd"));
			map.put("5start", paramMap.get("bottomOneStart"));
			map.put("5end", paramMap.get("bottomOneEnd"));
		} catch (Exception e) {
			throw e;
		}
		return map;
	}
	
}